package fr.upmc.i3s.upmcontact.listeners;

import fr.upmc.i3s.upmcontact.contents.MerchantInfo;
import fr.upmc.i3s.upmcontact.contents.Published;
import fr.upmc.i3s.upmcontact.contents.StudentLifeInfo;
import fr.upmc.i3s.upmcontact.contents.UpmcInfo;
import fr.upmc.i3s.upmcontact.views.dialogs.MerchantInfoDetailsDialog;
import fr.upmc.i3s.upmcontact.views.dialogs.StudentInfoDetailsDialog;
import fr.upmc.i3s.upmcontact.views.dialogs.UpmcInfoDetailsDialog;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.View.OnClickListener;

public class OnPublishedClickListener implements OnClickListener {
	
	private Fragment context;
	private Published pub;
	
	public OnPublishedClickListener(Fragment context, Published pub) {
		this.context = context;
		this.pub = pub;
	}

	@Override
	public void onClick(View v) {
		if(pub instanceof UpmcInfo) {
			Intent intent = new Intent(context.getActivity(), UpmcInfoDetailsDialog.class);
			intent.putExtra(UpmcInfoDetailsDialog.PARAM_INFO, pub);
			context.startActivity(intent);
			
		} else if (pub instanceof StudentLifeInfo) {
			Intent intent = new Intent(context.getActivity(), StudentInfoDetailsDialog.class);
			intent.putExtra(StudentInfoDetailsDialog.PARAM_INFO, pub);
			context.startActivity(intent);
			
		} else if (pub instanceof MerchantInfo) {
			Intent intent = new Intent(context.getActivity(), MerchantInfoDetailsDialog.class);
			intent.putExtra(MerchantInfoDetailsDialog.PARAM_INFO, pub);
			context.startActivity(intent);
		}
	}

}
